<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<c:set var="userUrl" value="${pageContext.request.contextPath}/user" scope="application"/>
<c:set var="base" value="${pageContext.request.contextPath}" scope="application"/>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Signin Template for Bootstrap</title>

    <!-- Bootstrap core CSS -->
    <link href="${userUrl}css/bootstrap.min.css" rel="stylesheet">


    <!-- Custom styles for this template -->
    <link href="signin.css" rel="stylesheet">


</head>

<body>

<div class="container">

    <form class="form-signin" action="${base}/user" method="post">
        <input type="hidden" name="method" value="userRegistere"/>
        <h2 class="form-signin-heading">注册</h2>
        <label for="inputUserName" class="sr-only">用户名</label>
        <input type="text" id="inputUserName" class="form-control" placeholder="用户名" name="userName" onchange="findUserReChecking(this,this.value)" required autofocus>
        <span id="userName"></span>
        <label for="inputPassword" class="sr-only">密码</label>
        <input type="password" id="inputPassword" class="form-control" placeholder="密码" name="userPassword" required>
        <button class="btn btn-lg btn-primary btn-block" type="submit">注册</button>
        <center>
            <a href="login.jsp">登陆</a>
            <a href="bak-registere.jsp">旧版注册</a>
        </center>
    </form>


</div> <!-- /container -->


</body>
<script>
    function findUserReChecking(obj,userName) {
        console.log(obj);
        var url = "${base}/user?method=findUserReChecking&userName=" + userName;
        $.get(url,null,function (result) {
            console.log(result)
            if ("success" == result){
                $("#userName").text("用户名可用");
            }
            if ("false" == result){
                $("#userName").text("用户名不可用");
            }
        })
    }
</script>
</html>
